import request, { fetchRequest } from '@/utils/request'
import type { UserState } from '@/store/modules/user/types'

export interface LoginData {
  username: string
  password: string
  imgCode: string
}

export interface LoginRes {
  token: string
}
// 登录
export const login = (data: LoginData) => request.post<LoginRes>('/auth/login', data)
// 退出
export const logout = () => request.get<LoginRes>('/user/logout')
// 用户信息
export const fetchUserInfo = (id: string) => request.get<UserState>(`/user/${id}`)
export const fetchUser = (params?: any) => fetchRequest({ api: 'user', ...params })
// 角色
export const fetchRole = (params?: any) => fetchRequest({ api: 'role', ...params })
// 菜单列表
export const fetchMenuList = (id?: string) => request.get(`/user/router/${id}`)
